import React, { Component } from 'react';
import { Icon, Button, Table, Switch, Form, Input, Modal } from 'antd';
import AddQuestionInput  from './AddQuestionInput';
import QuestionGroupTable  from './QuestionGroupTable';

const FormItem = Form.Item;


const columns = [
  { title: '问题列表', dataIndex: 'question_name', key: 'question_name' },
  { title: '操作', dataIndex: '', key: 'x', render: () => <a href="#">Delete</a> },
];

class QuestionsManager extends Component {

  constructor(props) {
    super(props)
    this.state={
      tableLoading:this.props.questionsTableLoading,
      termsId:this.props.location.query
    }
    this.toggleTableLoading=this.toggleTableLoading.bind(this)
  }
  componentWillMount() {
    // console.log(this.props)
    this.props.getQuestionsByTermsId(this.props.params.termsId);

  }
  toggleTableLoading(){
    this.setState({tableLoading:!this.state.tableLoading})
  }
  render() {
    const {questionList,questionFetching}=this.props.questions;
    const { termsId}=this.props.params;

    return (

           <div className="container-terms">
            <div className="add-columns">
             <AddQuestionInput 
                termsId={termsId} 
                addOneQuestion={this.props.addOneQuestion}
                />
            </div>
            <div className="show-columns">
              <QuestionGroupTable 
                 questionList={questionList}
                 questionFetching={questionFetching}

                 deleteOneQuestionById={this.props.deleteOneQuestionById} 
                 updateOneQuestionById={this.props.updateOneQuestionById}/>
            </div>
          </div>
    )
  }
}



QuestionsManager = Form.create()(QuestionsManager);








export default QuestionsManager
